package resfoods.config;

import feign.Logger;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * @ClassName FeignLogConfig
 * @since: 2023/8/26 10:29
 * @auth: kirito
 * @description:
 **/
@Configuration
public class FeignLogConfig {
    @Bean
    Logger.Level feignLoggerLever() {
        return Logger.Level.FULL;
    }

    /**
     * 请求拦截器 统一加入origin请求头信息
     * feign中的拦截器机制也是一个 责任链模式.
     */
    @Component
    public class CustomRequestInterceptor implements RequestInterceptor {

        @Override
        public void apply(RequestTemplate requestTemplate) {
            //requestTemplate 请求对象
            requestTemplate.header("source", "order-source");
        }
    }
}
